<?php
	define('CONFIG_FILE',true);
	include '../config.php';
	define('DB_FILE',true);
	
	require_once '../Tool/DB/SqlDBManager.class.php';

	session_start();
	if (empty($_SESSION["userType"])) {
		$url="../Index.php";
		include_once '../Tool/Common/Redirect.php';
		exit();
	}
	
	$AttendanceRecordID = intval($_REQUEST['AttendanceRecordID']);

	$sqlDBManager = new SqlDBManager();

	$sql1 = "select * from attendancerecord where AttendanceRecordID=?";
	$parameters1 = array($AttendanceRecordID);
	$res1=$sqlDBManager->execute_dql($sql1,$parameters1);

	if (!empty($res1)){
		$sql2="delete from attendancerecord where AttendanceRecordID=?";
		$parameters2 = array($AttendanceRecordID);
		$res2=$sqlDBManager->execute_dml($sql2,$parameters2);
		if($res2){
			echo json_encode(array('success'=>true));
		}else {
			echo json_encode(array('msg'=>'Cannot Delete Attendance!'));
		}
		
	} 
?>